<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%edivi_credit_order}}".
 *
 * @property int $id
 * @property string $order_no
 * @property string $bank_code
 * @property string $assurer_no
 * @property string $plat_no
 * @property string $busi_code
 * @property string $bank_type
 * @property int $car_type
 * @property int $sign_mode
 * @property int $download_mode
 * @property string $intention_price 意向车辆价格
 * @property string $estage_order_no e分期生成的订单号
 * @property int $status 0:征信发送成功;1:征信退回;2:分期退回;3:拒绝受理;4:授信通过;5:等待押品补录;6:材料补录;7:放款通知;8:分行审查通过;9:取消订单10:行方签署完合同通知;11:上送分期信息超期提现;12:押品补录超期提醒;100:开卡信息发送成功;101:分期信息发送成功;110:押品补录信息发送成功;120:材料补录信息发送成功
 * @property int $ypbl_status
 * @property int $clbu_status
 * @property string $bl_task_id
 * @property string $bl_task_type
 * @property int $app_uid
 *
 * @property EdiviCommonBackLogs[] $ediviCommonBackLogs
 * @property EdiviCreditOrderUsers[] $ediviCreditOrderUsers
 * @property EdiviOrderApply[] $ediviOrderApplies
 * @property EdiviOrderCard $ediviOrderCard
 * @property EdiviOrderClbl[] $ediviOrderClbls
 * @property EdiviOrderCompensationAssociates[] $ediviOrderCompensationAssociates
 * @property EdiviOrderDivi $ediviOrderDivi
 * @property EdiviOrderSendLogs[] $ediviOrderSendLogs
 * @property EdiviOrderYpbl[] $ediviOrderYpbls
 */
class EdiviCreditOrder extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%edivi_credit_order}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['order_no', 'bank_code', 'assurer_no', 'plat_no', 'busi_code', 'bank_type', 'intention_price', 'app_uid'], 'required'],
            [['car_type', 'sign_mode', 'download_mode', 'status', 'ypbl_status', 'clbu_status', 'app_uid'], 'integer'],
            [['intention_price'], 'number'],
            [['order_no', 'bank_code', 'assurer_no', 'estage_order_no', 'bl_task_id'], 'string', 'max' => 50],
            [['plat_no', 'bank_type', 'bl_task_type'], 'string', 'max' => 20],
            [['busi_code'], 'string', 'max' => 4],
            [['order_no'], 'unique'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'order_no' => Yii::t('app', 'Order No'),
            'bank_code' => Yii::t('app', 'Bank Code'),
            'assurer_no' => Yii::t('app', 'Assurer No'),
            'plat_no' => Yii::t('app', 'Plat No'),
            'busi_code' => Yii::t('app', 'Busi Code'),
            'bank_type' => Yii::t('app', 'Bank Type'),
            'car_type' => Yii::t('app', 'Car Type'),
            'sign_mode' => Yii::t('app', 'Sign Mode'),
            'download_mode' => Yii::t('app', 'Download Mode'),
            'intention_price' => Yii::t('app', '意向车辆价格'),
            'estage_order_no' => Yii::t('app', 'e分期生成的订单号'),
            'status' => Yii::t('app', '0:征信发送成功;1:征信退回;2:分期退回;3:拒绝受理;4:授信通过;5:等待押品补录;6:材料补录;7:放款通知;8:分行审查通过;9:取消订单10:行方签署完合同通知;11:上送分期信息超期提现;12:押品补录超期提醒;100:开卡信息发送成功;101:分期信息发送成功;110:押品补录信息发送成功;120:材料补录信息发送成功'),
            'ypbl_status' => Yii::t('app', 'Ypbl Status'),
            'clbu_status' => Yii::t('app', 'Clbu Status'),
            'bl_task_id' => Yii::t('app', 'Bl Task ID'),
            'bl_task_type' => Yii::t('app', 'Bl Task Type'),
            'app_uid' => Yii::t('app', 'App Uid'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviCommonBackLogs()
    {
        return $this->hasMany(EdiviCommonBackLogs::className(), ['edivi_credit_order_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviCreditOrderUsers()
    {
        return $this->hasMany(EdiviCreditOrderUsers::className(), ['edivi_credit_order_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviOrderApplies()
    {
        return $this->hasMany(EdiviOrderApply::className(), ['edivi_order_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviOrderCard()
    {
        return $this->hasOne(EdiviOrderCard::className(), ['edivi_credit_order_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviOrderClbls()
    {
        return $this->hasMany(EdiviOrderClbl::className(), ['edivi_credit_order_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviOrderCompensationAssociates()
    {
        return $this->hasMany(EdiviOrderCompensationAssociates::className(), ['edivi_credit_order_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviOrderDivi()
    {
        return $this->hasOne(EdiviOrderDivi::className(), ['edivi_credit_order_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviOrderSendLogs()
    {
        return $this->hasMany(EdiviOrderSendLogs::className(), ['edivi_credit_order_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviOrderYpbls()
    {
        return $this->hasMany(EdiviOrderYpbl::className(), ['edivi_credit_order_id' => 'id']);
    }
}
